<!DOCTYPE html>
<html dir="ltr" lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Tell the browser to be responsive to screen width -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<!-- Favicon icon -->
<link rel="icon" type="image/png" sizes="16x16" th:href="@{/assets/images/favicon.png}">
<title>任务列表·网络情报分析系统</title>
<!-- Custom CSS -->
<link th:href="@{/dist/css/style.min.css}" rel="stylesheet">
<link th:href="@{/dist/css/custom.css}" rel="stylesheet">
<link th:href="@{/assets/libs/sweetalert2/dist/sweetalert2.min.css}"
	rel="stylesheet">
<link rel="stylesheet" type="text/css"
	th:href="@{assets/libs/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css}">
<!--     <script src="//at.alicdn.com/t/font_1709263_w16payhc3l.js"></script>
 -->
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>

<body>
	<!-- ============================================================== -->
	<!-- Preloader - style you can find in spinners.css -->
	<!-- ============================================================== -->
	<div class="preloader">
		<div class="lds-ripple">
			<div class="lds-pos"></div>
			<div class="lds-pos"></div>
		</div>
	</div>
	<!-- ============================================================== -->
	<!-- Main wrapper - style you can find in pages.scss -->
	<!-- ============================================================== -->
	<div id="main-wrapper">
		<div th:replace="common/header::header"></div>
		<div th:replace="common/publicoptionl_left::publicoptionl_left"></div>
		<!-- ============================================================== -->
		<!-- End Left Sidebar - style you can find in sidebar.scss  -->
		<!-- ============================================================== -->
		<!-- Page wrapper  -->
		<!-- ============================================================== -->
		<div class="page-wrapper">

			<div class="right-part right-content">
				<!-- nav start-->
				<div class="page-breadcrumb">
					<div class="row">
						<div class="col-lg-5 align-self-center">
							<div class="d-flex align-items-center">
								<nav aria-label="breadcrumb">
									<ol class="breadcrumb">
										<li class="breadcrumb-item">事件分析</li>
										<li class="breadcrumb-item">任务列表</li>
									</ol>
								</nav>
							</div>
						</div>
						<div class="col-lg-7 align-self-center">
							<div
								class="d-flex no-block justify-content-end align-items-center data-number-min">
								<button type="button"
									class="btn btn-outline-secondary btn-sm bnone"
									id="deleteexportlist">
									<i class="fas fa-trash-alt"></i> 批量删除
								</button>
							</div>
						</div>
					</div>
				</div>
				<!-- nav end-->
				<div class="p-20">
					<!--  start-->
					<div class="card">
						<div class="card-body p-0">
							<div class="p-15 b-b">
								<div class="d-flex align-items-center justify-content-between">
									<div class="project-group">
									
										<strong>共有</strong> <span class="label label-info" id="totalnum">0</span> <span>个分析任务</span>
									</div>
									<div class="input-group " style="width: 500px;">

										<input type="text" class="form-control"
											placeholder="输入方案名称..." aria-label=""
											aria-describedby="basic-addon1" id="namesearch">
										<div class="input-group-append">
											<button type="button"
												class="btn waves-effect waves-light btn-secondary  d-inline-block" onclick="search()">
												<!-- <i class="fas fa-search"></i> -->
												搜索
											</button>
										</div>
									</div>
								</div>
							</div>

							<div class="table-responsive" id="eventAnalysislist">
								<!-- line title start -->
								<div class="event-analysisList-title publicoption-list-box">
									<div class="publicoption-cnb">
										<div class="custom-control custom-checkbox pro-selectall"
											style="display: inline-block;">
											<input type="checkbox" class="custom-control-input sl-all"
												id="cstall"> <label class="custom-control-label"
												for="cstall"></label>
										</div>
									</div>
									<div>事件名称</div>
									<div>事件关键词</div>
									<div>任务时间段</div>
									<div>创建时间</div>
									<div>状态</div>
									<div>操作</div>
								</div>
								<!-- line title end -->
								<div id="loadingdata">
								</div>
								
								
							</div>
							<!-- pages start -->
							<div class="all-pagebox m-r-20 m-b-20 m-t-20">
								<ul class="pagination float-right" id="page">
									<!-- <li class="page-item disabled">
                                <a class="page-link" href="javascript:void(0)" tabindex="-1">上一页</a>
                            </li>
                            <li class="page-item active"><a class="page-link" href="#">1</a></li>
                            <li class="page-item">
                                <a class="page-link" href="avascript:void(0)">2 <span class="sr-only">(current)</span></a>
                            </li>
                            <li class="page-item"><a class="page-link" href="avascript:void(0)">3</a></li>
                            <li class="page-item">
                                <a class="page-link" href="avascript:void(0)">下一页</a>
                            </li> -->
								</ul>
							</div>
							<!-- pages end -->

						</div>
					</div>
					<!-- 24h end -->
				</div>
				<!-- ============================================================== -->
				<!-- footer start  -->
				<!-- ============================================================== -->
				<div class="page-footer">
                    © 2014-<span id="currentyear"></span> 南京涌亿思信息技术有限公司  苏ICP备17066984号-1
                </div>
				<!-- ============================================================== -->
				<!-- footer end  -->
				<!-- ============================================================== -->
			</div>
		</div>
		<!-- ============================================================== -->
		<!-- End Page wrapper  -->
		<!-- ============================================================== -->
	</div>
	<!-- ============================================================== -->
	<!-- End Wrapper -->
	<!-- ============================================================== -->
	<!-- All Jquery -->
	<!-- ============================================================== -->
	<script th:src="@{/assets/libs/jquery/dist/jquery.min.js}"></script>
	<!-- Bootstrap tether Core JavaScript -->
	<script th:src="@{/assets/libs/popper.js/dist/umd/popper.min.js}"></script>
	<script th:src="@{/assets/libs/bootstrap/dist/js/bootstrap.min.js}"></script>
	<!-- apps -->
	<script th:src="@{/dist/js/app.min.js}"></script>
	<script th:src="@{/dist/js/app.init.light-sidebar.js}"></script>
	<script th:src="@{/dist/js/app-style-switcher.js}"></script>
	<!-- slimscrollbar scrollbar JavaScript -->
	<script
		th:src="@{/assets/libs/perfect-scrollbar/dist/perfect-scrollbar.jquery.min.js}"></script>
	<script th:src="@{/assets/extra-libs/sparkline/sparkline.js}"></script>
	<!--Wave Effects -->
	<script th:src="@{/dist/js/waves.js}"></script>
	<!--Menu sidebar -->
	<script th:src="@{/dist/js/sidebarmenu.js}"></script>
	<!--Custom JavaScript -->
	<script th:src="@{/dist/js/custom.min.js}"></script>
	<script
		th:src="@{/assets/libs/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js}"></script>
	<script
		th:src="@{/assets/libs/sweetalert2/dist/sweetalert2.all.min.js}"></script>
	<script th:src="@{/dist/js/pages.js}"></script>
	<script th:src="@{/dist/js/publicoption.js?unixtemp=888888}"></script>
	<script th:src="@{/dist/eventAnalysisReport.js?unixtemp=888888}"></script>
	<script th:src="@{/assets/libs/block-ui/jquery.blockUI.js}"></script>
	<script th:src="@{/dist/baidu/baidu_statistics.js}"></script>
	<script>
	$("#currentyear").text((new Date()).getFullYear());
	
	
	function search(){
		publicoptionlist(1);
	}
    
    publicoptionlist(1);
    
    function publicoptionlist(pagenum){
    	loading("#loadingdata");
    	
    	let searchkeyword  = $("#namesearch").val();
    	$.ajax({
			url : ctxPath + 'publicoption/list',
			type : 'post',
			dataType : 'json',
			data : {pagenum:pagenum,searchkeyword:searchkeyword},
			success : function(res) {
				let totalnum = res.dataCount;
				$("#totalnum").text(totalnum);
				
				
				console.info(res);
				let list = res.list;
				let eventAnalysisliststr = '';
				//$(".publicoption-list-box").remove();
				$(".publicoption-list-box:nth-of-type(n+2)").remove();
				for(let i=0;i<list.length;i++){
					eventAnalysisliststr += 
						'<div class="table-hover event-analysisList-content publicoption-list-box">'+
	                   ' <div class="publicoption-chb">'+
	                '<div class="custom-control custom-checkbox">'+
	                    '<input type="checkbox" value="'+list[i].id+'" class="custom-control-input" id="cst'+(i+1)+'">'+
	                    '<label class="custom-control-label" for="cst'+(i+1)+'"></label>'+
	                '</div>'+
	            '</div>'+
	            '<div class="text-over" title="'+list[i].eventname+'">'+list[i].eventname+'</div>'+
	            '<div>'+list[i].eventkeywords+'</div>'+
	           ' <div class="text-over">'+list[i].eventstarttime.substring(0,16)+' - '+list[i].eventendtime.substring(0,16)+'</div>'+
	            '<div class="text-over">'+list[i].createtime.substring(0,16)+'</div>';
	            
	            if(list[i].status==1){
	            	eventAnalysisliststr+= '<div>'+
		                '<i class="mdi mdi-close-circle zm"></i>'+
		                '创建失败'+
		            '</div>';
	            }else if(list[i].status==2){
	            	eventAnalysisliststr+= '<div>'+
	                '<i class="mdi mdi-close-circle-outline zx"></i>'+
	                '正在生成'+
	            '</div>';
	            }else if(list[i].status==3){
	            	eventAnalysisliststr+= '<div>'+
	                '<i class="mdi mdi-check-circle-outline zx"></i>'+
	                '生成成功'+
	            '</div>';
	            	
	            }
	            eventAnalysisliststr+= '<div>'+
	                '<i class="mdi mdi-eye-outline" title="查看" onclick="editEvent('+list[i].id+','+list[i].status+')"  id="exportthis"></i>'+
	               ' <i class="fas fa-pencil-alt" title="修改" onclick="editEvent1('+list[i].id+')" id="editpublicoption"></i>'+
	                '<i class="fas fa-trash-alt" title="删除" onclick="deletedata('+list[i].id+')" id="deletepublicoption"></i>'+
	            '</div>'+
	        '</div>';
				}
				$("#eventAnalysislist").append(eventAnalysisliststr);
				$("#loadingdata").empty();
				page(pagenum, res.pageCount);
				 if (list.length == 0) {
				        nodata('#eventAnalysislist', '暂无数据！')
				    }
				
				
				
			},
			error : function(xhr, ajaxOptions, thrownError) {
				console.log(xhr);
				if (xhr.status == 403) {
					window.location.href = ctxPath + "login";
				}
			}
    });
    	
    
    }
    
    function page(currentPage, totalPages){
    	if(totalPages < 1) totalPages = 1;
        $("#page").bootstrapPaginator({
            bootstrapMajorVersion: 3, //版本
            currentPage: currentPage, //当前页数
            numberOfPages: 20, //每次显示页数
            totalPages: totalPages, //总页数
            shouldShowPage: true, //是否显示该按钮
            useBootstrapTooltip: false,
            onPageClicked: function (event, originalEvent, type, page) {
            	pageNum = page;
            	publicoptionlist(pageNum);
            }
        });
    }
    
    
    
    // 复选框点击
    $('body').on('click', '.projectCheck', function () {
        $('.projectCheck').each(function () {
            if (!$(this).is(":checked")) {
                $('#cstall').prop('checked', false);
                return;
            }
        });
    });
    
    
    
    
    
    // createEvent
    $("#createEvent").click(function (param) {
        createEvent()
     })
     
    
    
    /* $('#editpublicoption').on('click', function() {
    	editEvent(1);
    }); */
    
    function exportthis(){
    	editEvent(1);
    }
    /* function updatethis(id){
    	editEvent(1);
    } */
    
    
    function editEvent(id,status) {
    	if(status=='2'||status=='1'){
    		showtips("事件分析报告暂未生成成功，请等待");
    	}else{
    		window.location.href = ctxPath + 'publicoption/reportdetail/'+id;
    	}
    	
    	
    	
    	
    	
     }
    
    
    
    function editEvent1(id) {
    	$.ajax({
			url : ctxPath + 'publicoption/getdatabyid',
			type : 'post',
			dataType : 'json',
			data : {id:id},
			success : function(res) {
				console.info(res);
				let publicoption = res.publicoption;
				var eventHtml =
			           '<div class="shadebox" id="confirmsure">'+
			           '    <div class="showCreateEvent"> '+
			           '        <div class="event-box">'+
			           '            <div class="event-box-header"> '+
			           '                <h5 class="modal-title">分析任务</h5>'+
			           '                <i class="mdi mdi-close-circle-outline font-18 cursor-po" id="closethis"></i>'+
			           '            </div>'+
			           '            <div class="event-box-body">'+
			           '                <div class="event-line">'+
			           '                    <div><span>*</span>舆情研判任务名称</div>'+
			           '                    <div class="input-group">'+
			           '                        <input type="text" class="form-control" id="publicoption_eventname" placeholder="舆情研判任务名称" value="'+publicoption.eventname+'" maxlength="15"/>'+
			           '                    </div>'+
			           '                </div>'+
			           '                <div class="event-line">'+
			           '                    <div><span>*</span>任务时间段</div>'+
			           '                    <div class="input-group event-time-box">'+
			           '                        <input type="date" class="form-control" id="publicoption_eventstarttime" value="'+publicoption.eventstarttime.substring(0,10)+'">'+
			           '                        <input type="date" class="form-control" id="publicoption_eventendtime" value="'+publicoption.eventendtime.substring(0,10)+'">'+
			           '                    </div>'+
			           '                </div>'+
			           '                <div class="event-line">'+
			           '                    <div><span>*</span>事件涉及词</div>'+
			           '                    <div class="input-group">'+
			           '                        <textarea class="form-control" name="keywords" id="publicoption_eventkeywords" cols="" rows="4" placeholder="关键词之间请用以下“+”、“|”、“（”、“）"隔开">'+publicoption.eventkeywords+'</textarea>'+
			           '                    </div>'+
			           '                </div>'+
			           '                <div class="event-line">'+
			           '                    <div>事件屏蔽词</div>'+
			           '                    <div class="input-group">'+
			           '                        <textarea class="form-control" name="keywords" id="publicoption_eventstopwords" cols="" rows="4" placeholder="屏蔽词之间请用以下“+”、“|”、“（”、“）"隔开">'+publicoption.eventstopwords+'</textarea>'+
			           '                    </div>'+
			           '                </div>'+
			           '            </div>'+
			           '            <div class="modal-footer no-border">'+
			           '                <button type="button" class="btn btn-info" id="confirm" onclick="confirm('+publicoption.id+')"> 确定</button> '+
			           '                <button type="button" class="btn btn-secondary" id="cancel">取消</button>'+
			           '            </div>'+
			           '        </div>'+
			           '    </div>'+
			           '</div>'

			       $("body").append(eventHtml)

			       $("#closethis").click(function (param) { 
			           $("#confirmsure").remove()
			        })
			       
			         	
			        $("#cancel").click(function (param) { 
			           $("#confirmsure").remove()
			        })  
				
			},
			error : function(xhr, ajaxOptions, thrownError) {
				console.log(xhr);
				if (xhr.status == 403) {
					window.location.href = ctxPath + "login";
				}
			}
    });
     }
    
    
    
    //批量删除按钮
    $("#deleteexportlist").click(function(){
    	  var Ids = [];
          let i = 0;
  	$("input[class='custom-control-input']:checked").each(function(i){
  		Ids.push($(this).val());
  	})
  	deletedata(Ids);
    });
    
    
    
    
  //执行删除操作
    function deletedata(Ids){
    	if (Ids.length == 0) {
            showtips("未选择删除事件分析报告！");
        } else {
            var confirmhtml =
                '<div class="shadebox" id="confirmsure">' +
                '    <div class="modal-dialog" role="document"> ' +
                '        <div class="modal-content">' +
                '            <div class="modal-header align-flexend no-border"> ' +
                '                <h5 class="modal-title">提示</h5>' +
                '                <i class="mdi mdi-close-circle-outline font-18 cursor-po" id="closethis"></i>' +
                '            </div>' +
                '            <div class="modal-body" style="padding:0 1rem;">' +
                '                <div class="input-group alcenter"><i class="fa fa-exclamation-circle m-r-10 font-20"></i> 此操作将删除该事件分析报告, 是否继续?' +
                '                </div>' +
                '            </div>' +
                '            <div class="modal-footer no-border">' +
                '                <button type="button" class="btn btn-info" id="confirm"> 确定</button> ' +
                '                <button type="button" class="btn btn-secondary" id="cancel">取消</button>' +
                '            </div>' +
                '        </div>' +
                '    </div>' +
                '</div>'
            $("body").append(confirmhtml)
            $("#closethis").click(function (param) {
                $("#confirmsure").remove()

            })
            $("#cancel").click(function (param) {
                $("#confirmsure").remove()
            })
            $("#confirm").click(function (param) {
                $.ajax({
                    url: ctxPath + 'publicoption/deletepublicoptioninfo',
                    type: 'post',
                    dataType: 'json',
                    data: {
                    	Ids: JSON.stringify(Ids)
                    },
                    success: function (res) {
                    	console.info(typeof(res));
                        if (res.status=200) {
                            showtips("事件分析报告删除成功！");
                            setTimeout(() => {
                            	window.location.href = ctxPath + 'publicoption';
                            }, 1000);
                            //sendProjectList(groupid, $('#currentName').val().trim(), 1);
                            
                        } else {
                            showtips("事件分析报告删除失败！");
                        }
                    },
                    error: function (xhr, ajaxOptions, thrownError) {
                        if (xhr.status == 403) {
                            window.location.href = ctxPath + "login";
                        } else {
                            $("#popularinformation").css({"position": "relative", "min-height": "300px"})
                            dataerror("#popularinformation")
                        }
                    }
                });
                $("#confirmsure").remove()
            })
//            }
        }
    }
    
    function confirm(id){
		let eventname =$("#publicoption_eventname").val();
     	console.info(eventname);
     	let eventkeywords =$("#publicoption_eventkeywords").val();
     	let eventstarttime =$("#publicoption_eventstarttime").val();
     	let eventendtime =$("#publicoption_eventendtime").val();
     	let eventstopwords =$("#publicoption_eventstopwords").val();
     	if(eventname==null||eventname==""){
     		showtips("请输入舆情研判任务名称！");
        	return;
     	}
     	if(eventstarttime==null||eventstarttime==""){
     		showtips("请选择任务开始时间！");
        	return;
     	}
     	if(eventendtime==null||eventendtime==""){
     		showtips("请选择任务结束时间！");
        	return;
     	}
     	if(eventkeywords==null||eventkeywords==""){
     		showtips("请输入事件涉及词！");
        	return;
     	}
     	$.ajax({
			url : ctxPath + 'publicoption/updatedatabyid',
			type : 'post',
			dataType : 'json',
			data : {
				id:id,
				eventname:eventname,
				eventkeywords:eventkeywords,
				eventstarttime:eventstarttime,
				eventendtime:eventendtime,
				eventstopwords:eventstopwords
				},
			success : function(res) {
				let status = res.status;
				if(status==200){
					$("#confirmsure").remove()
					
					$.blockUI({
			            message: "更新成功",
			            fadeIn: 700,
			            fadeOut: 700,
			            timeout: 3000,
			            showOverlay: false,
			            centerY: false,
			            css: {
			                width: '250px',
			                top: '20px',
			                left: '',
			                right: '20px',
			                border: 'none',
			                padding: '15px 5px',
			                backgroundColor: '#000',
			                '-webkit-border-radius': '10px',
			                '-moz-border-radius': '10px',
			                opacity: 0.9,
			                color: '#fff'
			            }
			        });
        setTimeout(() => {
        	window.location.href = ctxPath + 'publicoption';
        }, 1000);
					
				}
				
			},
			error : function(xhr, ajaxOptions, thrownError) {
				console.log(xhr);
				if (xhr.status == 403) {
					window.location.href = ctxPath + "login";
				}
			}
    });
       
	}
    
    
    
    
    
    
    
    
    </script>
	<script th:inline="javascript" type="text/javascript">
    let projectid = '';
    let groupId = '';
	
    $('.navLi').click(function(){
    	jumpNavLocation($(this).data('type'), groupId, projectid);
    })
</script>



</body>

</html>